import configparser
conf = configparser.ConfigParser()
conf.read("config.ini", encoding="GBK")

sections = conf.sections()
print('获取配置文件所有的section', sections)

options = conf.options('ExtensionType')
print('获取指定section下所有option', options)


items = conf.items('ExtensionType')
print('获取指定section下所有的键值对', items)


value = conf.get('ExtensionType', 'type')
print('获取指定的section下的option', type(value), value)

value1 = conf.get('DirectoryList', 'source_directory')
print('获取指定的section下的option', type(value1), value1)
value11 = value1.split(',')
for v1 in value11:
    print('v1=',v1)




def get_config_values(sections,items):
    value = ''
    try:
        value  = conf.get(sections, items)
    except Exception as e:
        print('错误类型： ', e)
    return  value
values = []
values.append(('ExtensionType','type'))
values.append(('DirectoryList','source_directory'))
for v in values:
    print(v[0])
    value = get_config_values(v[0], v[1])
    if value.__len__() == 0:
        print('无数据')
    else:
        print('成功')
# value = get_config_values('DirectoryList','source_directory')
# if value.__len__() == 0:
#     print('无数据')
# else:
#     print('成功')
# # print('VALUE=',value)